package com.heima.controller;

import com.heima.pojo.dto.VendingMachineDTO;
import com.heima.pojo.dto.VendingMachinePageDTO;
import com.heima.pojo.vo.VendingMachineDetailsVO;
import com.heima.result.PageResult;
import com.heima.service.VendingMachineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/vm")
public class VendingMachineController {
//TODO
    @Autowired
    VendingMachineService vendingMachineService;

    /**
     * 设备搜索
     * @param dto
     * @return
     */
    @GetMapping("/search")
    public PageResult<VendingMachineDetailsVO> getNodeDetails(VendingMachinePageDTO dto) {
        PageResult<VendingMachineDetailsVO> pagevmd = vendingMachineService.pagevmd(dto);
        return pagevmd;
    }
    /**
     * 新增设备
     */
    @PostMapping
    public boolean add(@RequestBody VendingMachineDTO dto){
        boolean result =vendingMachineService.add(dto);
        return result;
    }
}
